var path = require('path');

var node_dir = __dirname + '/node_modules';

var options = {
    style: true,
    libraryDirectory: 'lib',       // default: lib
    libraryName: 'antd'            // default: antd
};

module.exports = {
    entry: './src/main/js/app.js',
    devtool: 'sourcemaps',
    cache: true,
    debug: true,
    output: {
        path: __dirname,
        filename: './target/classes/static/built/bundle.js'
    },
    module: {
        loaders: [
            {
                test: /\.jsx?$/,
                exclude: /(node_modules)/,
                loader: 'babel-loader',
                query: {
                    presets: ['es2015', 'react'],
                    plugins: [
                        ['import', [{libraryName: "antd", style: true}]]  // 加载 less 文件
                    ]
                }
            },
            {
                test: /.less/,
                loader: 'style-loader!css-loader!less-loader'
            },
            {test: /\.css$/, loader: "style!css"}
        ]
    },
    babel: {
        plugins: [['antd', options]]
    }
};